# 导入redis模块
from redis import StrictRedis

class Config:

    DEBUG = None
    SECRET_KEY = '5eSmF70F8o5zI/UVZdRgGb8GTs4OEH/l+G7g9MExZlliClJ80Zl1PCytE44T'
    # mysql配置信息
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@localhost/news_info'
    SQLALCHEMY_TRACK_MODIFICATIONS = False  # 动态追踪修改

    # 定义redis的主机和端口号
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # 实现状态保持，配置session信息存储在redis中
    SESSION_TYPE = 'redis'
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    # session有效期的设置，Flask内置的session有效期配置
    PERMANENT_SESSION_LIFETIME = 86400

# 封装不同环境下的配置类,开发模式、生产模式
class DevelopmentConfig(Config):
    DEBUG = True

class ProductionConfig(Config):
    DEBUG = False

# 定义字典，实现不同环境下的配置类的映射
config_dict = {
    'development':DevelopmentConfig,
    'production':ProductionConfig
}

